const http = require('../utils/http')

const HTTP = new http.HTTP()

// 获取全部课程
export function getCourses(pageNum, pageSize, callback) {
  let params = {
    pageNum,
    pageSize
  }
  HTTP.request('/course/all', 'GET', params, res => {
    callback(res)
  })
}

// 获取单个课程详情
export function getCourseDetail(id, callback) {
  let params = {}
  HTTP.request(`/course/info/${id}`, 'GET', params, res => {
    callback(res)
  })
}

// 搜索课程
export function searchCourse(keywords, pageNum, pageSize, callback) {
  let params = {
    keywords,
    pageNum,
    pageSize
  }
  HTTP.request('/course/search', 'GET', params, res => {
    callback(res)
  })
}
export function courseAll(params,callback){

  HTTP.request('/course/all/'+params.userid, 'GET', params, res => {
    callback(res)
  })
}
export function courseGetSchedulesByIdAndStatus(params,callback){
  HTTP.request("/course/getMySchedulesByIdAndStatus","GET",params,res=>{
    callback(res)
  })
}
export function courseSignIn({targetActivityId, volunteerId},callback){

  HTTP.request("/course/signIn/"+targetActivityId,"PUT",{targetActivityId, volunteerId},res=>{
    callback(res)
  })
}
export function courseLeave(params,callback){
  console.log(params)
  HTTP.request("/course/leave","POST",params,res=>{
    callback(res)
  })
}
export function courseAllorderByStatus(params,callback){
  HTTP.request("/course/allorderByStatus","GET",params,res=>{
    callback(res)
  })
}

export function courseAllorder(params,callback){
  HTTP.request("/course/allMyOrder","GET",params,res=>{
    callback(res)
  })
}

export function getCourseByStatus(params,callback){
  HTTP.request("/course/getCourseByStatus","GET",params,res=>{
    callback(res)
  })
}
